Skip to content

Read ultrasound spacing from SequenceOfUltrasoundRegions#863

Merged
PaulHax merged 9 commits intoKitware:mainfrom
PaulHax:ultrasound-spacing
May 8, 2026
Merged

Read ultrasound spacing from SequenceOfUltrasoundRegions#863
PaulHax merged 9 commits intoKitware:mainfrom
PaulHax:ultrasound-spacing

Conversation

@PaulHax
Copy link
Copy Markdown
Collaborator

@PaulHax PaulHax commented Apr 16, 2026

Applies PhysicalDeltaX/Y (cm) from the first US region to the VTK image spacing when modality is US, so rulers show physical mm instead of pixel counts.

Ultrasound DICOM files:

https://raw.githubusercontent.com/pydicom/pydicom/main/src/pydicom/data/test_files/examples_ybr_color.dcm

https://raw.githubusercontent.com/pydicom/pydicom-data/master/data_store/data/color3d_jpeg_baseline.dcm

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit b708fe5
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/69fe3c87ce774c000836b0bc
😎 Deploy Preview https://deploy-preview-863--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@PaulHax PaulHax force-pushed the ultrasound-spacing branch 3 times, most recently from b505b0e to fed8bf2 Compare April 21, 2026 21:31
@PaulHax PaulHax requested a review from arhowe00 May 4, 2026 16:21
@PaulHax PaulHax force-pushed the ultrasound-spacing branch 7 times, most recently from 02f444e to 5292555 Compare May 8, 2026 19:38
PaulHax added 9 commits May 8, 2026 15:41
…r spec

Per DICOM PS3.3 C.8.5.5.1.15, code 3 (cm) is the only spatial spacing
unit defined for PhysicalUnitsXDirection / YDirection — codes 0, 1, 2,
4–12 cover none / percent / dB / seconds / hertz / dB/sec / cm/sec /
cm² / cm²/sec / cm³ / cm³/sec / degrees. Replace the strict cm equality
check with a unitToMm helper that returns 10 for cm and null for
everything else, applied per axis. Functionally equivalent to the
previous strict check, but isolates the unit-to-spacing mapping in one
tested place and adds a clear extension point if a vendor exception
ever needs to be honoured.
VTK image data has a single global spacing, so a multi-region ultrasound
(e.g. dual-pane B-mode + Doppler) cannot be fully represented. Surface
the total region count alongside the first region's spacing and warn in
the console when more than one region exists, so the partial-coverage
limitation is visible rather than silent.
Stop encoding UltrasoundRegions as a JSON string under a magic key on
the DICOM tag pair array and decoding it back. Expose it as a typed
property on MetaLoader, surface it on Chunk, and read it directly in
DicomChunkImage. The tag pair array now only contains DICOM tag/value
pairs.
A silent catch in parseUltrasoundRegionFromBlob meant a malformed
DICOM or a parser bug would fall back to default 1mm spacing without
any indication. Surface the error via console.warn so the silent
fallback is at least visible.
The Data panel only renders Spacing for non-DICOM images
(ImageDataBrowser filters via isRegularImage), so a US DICOM
never produces a "Spacing: (...)" caption — earlier attempts
to assert against that surface failed on a clean CI run.

Drop a ruler at a known canvas-pixel offset and read the
measurement from the Annotations panel. With the spacing fix
the ruler reports ~49 mm at the shared 1200×800 viewport;
without the fix the 1 mm/px fallback would yield ~97 mm. A
wide ±8 mm tolerance absorbs runner-to-runner canvas jitter
while still excluding the fallback.
- Correct PhysicalUnitsX/Y unit-code table per DICOM PS3.3 C.8.5.5
  (10=cm³, 11=cm³/sec, 12=degrees; previously labelled 10 as degrees)
  and extend the negative test to codes 11–12.
- Warn in the console when neither X nor Y direction is centimetres,
  parallel to the existing multi-region warning, so a 1mm fallback is
  no longer silent.
- Replace `null` with `undefined` for absent ultrasound regions so
  consumers handle a single absence state instead of three.
decodeUltrasoundRegion throws on truncated FD/US bytes. Mirror the
file path's try/catch in DicomMetaLoader so a malformed sequence
can't abort the metadata stream.

Also align the unit-code comment to decimal (matches the spec test)
and note that applyUltrasoundSpacing reads only chunks[0].
@PaulHax PaulHax force-pushed the ultrasound-spacing branch from 5292555 to b708fe5 Compare May 8, 2026 19:41
@PaulHax PaulHax added this pull request to the merge queue May 8, 2026
Merged via the queue into Kitware:main with commit 693b743 May 8, 2026
8 checks passed
@PaulHax PaulHax deleted the ultrasound-spacing branch May 8, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant